package GUI.dedicatedWin;

import java.awt.Dimension;

import gamePlus.server.GameServer;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class DedicatedServerWindow extends JFrame {
	class serverCaller implements Runnable{

		@Override
		public void run() {
			while(true) {
				serverData.setText(server.getServerDataForDedicated());
				serverData.repaint();
				serverData.revalidate();
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
		
	}
	private JPanel mainPanel;
	private JLabel serverData;
	private GameServer server;
	
	public DedicatedServerWindow(int port, String serverName, String password, String adminPassword) {
		mainPanel = new JPanel();
		serverData = new JLabel();
		setTitle(serverName);
		setVisible(true);
		setMinimumSize(new Dimension(300, 100));
		setContentPane(mainPanel);
		mainPanel.add(serverData);
		server = new GameServer(port, serverName, password, adminPassword);
		new Thread(new serverCaller()).start();
	}
}
